
// 55.跳跃游戏
class Solution {
public:
    bool canJump(vector<int>& nums) {
        // 使用贪心来进行解决
        int n = nums.size();
        int ret = 0;

        int left = 0 , right = 0;
        while(left <= right)
        {
            if(right >= n - 1) return true;
            int tmp = 0;
            ret++;
            for(int i = left ; i <= right ; i++)
                tmp = max(tmp , i + nums[i]);
            left = right + 1 , right = tmp;
        }
        return false;
    }
};